<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/9/16
  Time: 9:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>管理员管理</title>
        <style>
            .layui-table-cell {
                /* height: auto !important;*/
                white-space: normal;
                width: 50px;
            }
        </style>
        <meta charset="utf-8">
        <link href="../layui/css/layui.css" rel="stylesheet">
        <script src="../js/jquery-1.12.4.js" type="text/javascript"></script>
        <script src="../layui/layui.js" type="text/javascript"></script>
        <script type="text/javascript">
            layui.use(['table','form'],function () {
                var table = layui.table;
                var form = layui.form;

                //数据展示
                table.render({
                    elem: '#articleTable',
                    url: '${pageContext.request.contextPath}/article/selectArticle', //数据接口
                    page: true, //开启分页
                    toolbar:"#articleToolbar",
                    cols: [[ //表头
                        {type:"checkbox"},
                        { title: '文章编号',field: 'articleId', width:150, sort: true,align:'center'},
                        {title: '文章名',field: 'articleName',align:'center'},
                        {title: '文章图片',templet:"#imgTemplet",align:'center'},
                        {title: '文章简介',field: 'articleContent',align:'center'},
                        {title: '上架时间',field: 'articleDate',align:'center'},
                        {title: '所属上师编号',templet:"<div>{{d.guru.guruId}}</div>",align:'center'},
                        {title: '操作',templet:"#doTemplet",align:'center'}
                    ]]
                });
            })
        </script>
        <script type="text/html" id="doTemplet">
            <button type="button" class="layui-btn" onclick="updateGuru('{{d.guruId}}')">
                修改
            </button>
            <button type="button" class="layui-btn layui-btn-danger" onclick="deleteGuru('{{d.guruId}}')">
                删除
            </button>
        </script>
        <script type="text/html" id="imgTemplet">
            <img src="${pageContext.request.contextPath}{{d.articleImage}}" width="100px"/>
        </script>
    </head>
    <body>
        <%--管理员展示的数据表格--%>
        <table id="articleTable" lay-filter="article_table"></table>

        <%--数据表格绑定工具栏--%>
        <div id="articleToolbar" style="display: none;">
            <button type="button" class="layui-btn" onclick="addGuru()">
                <i class="layui-icon layui-icon-add-1"></i>添加文章
            </button>
            <button type="button" class="layui-btn layui-btn-danger" onclick="multiDelete()">
                <i class="layui-icon layui-icon-delete"></i>批量删除
            </button>
        </div>
    </body>
</html>
